# -*- coding: utf-8 -*-
# @Time : 2024/2/1 17:09
# @Author : ZH
# @File : 66.py
# @Software: PyCharm
from typing import List


class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        end_data = []
        gentle = 0
        for index in range(len(digits)):
            if index == 0:
                num = digits[len(digits) - index - 1] + 1 + gentle
                gentle = num // 10
                end_data.insert(0, num % 10)
                continue
            else:
                if gentle:
                    num = digits[len(digits) - index - 1] + gentle
                    gentle = num // 10
                    end_data.insert(0, num % 10)
                else:
                    end_data.insert(0, len(digits) - index - 1)

        if gentle:
            end_data.insert(0, gentle)
        return end_data